var mDoc = getRelateDocument();
var ztxt = mDoc.getItemValueAsString("ztxt_mc");
var phxt = mDoc.getItemValueAsString("phxt_mc");
if (!isNotNull(ztxt) && !isNotNull(phxt)) {
    var cid = mDoc.getId();
    var sql = "select '" + getDomainid() + "' as domainid, sc.item_ztxt_mc, sc.item_phxt_mc from tlk_setuo_carryout sc where id = (select parent from tlk_clause_present cp where cp.id = '" + cid + "')";
    var sqlResult = findBySQL(sql);
    if (null != sqlResult) {
        ztxt = sqlResult.getItemValueAsString("ztxt_mc");
        phxt = sqlResult.getItemValueAsString("phxt_mc");
    }
}
var xt = (isNotNull(phxt) ? ztxt + ";" + phxt : ztxt);
var array = splitText(xt, ";");
var xtStr = "('AAA";
for (var i = 0; i < array.length; i++) {
    xtStr = xtStr + "','" + array[i];
}
xtStr = xtStr + "')";

var search_pt = mDoc.getItemValueAsString("pt_search");
var search_xt = mDoc.getItemValueAsString("xt_search");
var search_zxt = mDoc.getItemValueAsString("zxt_search");
var search_sl = mDoc.getItemValueAsString("sl_search");
var search_mk = mDoc.getItemValueAsString("mk_search");
var search_sljc = mDoc.getItemValueAsString("sljc_search");

var sql =
    " select '" + getDomainid() + "' as domainid, sn.id as id, sn.ITEM_SYSTEM_TYPE, sn.item_app_name, sn.item_app_name_son, " +
    " ina.item_instance_name, ms.item_module from tlk_system_name sn" +
    " left join tlk_instance_name ina on(" +
    " case when(sn.item_app_name_son is null or sn.item_app_name_son = '') then sn.item_app_name" +
    " else concat(sn.item_app_name, '-', sn.item_app_name_son) end) = ina.item_system_name" +
    " left join tlk_mod_sys ms on ms.item_plat = sn.ITEM_SYSTEM_TYPE" +
    " and ms.item_system = sn.item_app_name and ms.item_sonsystems = sn.item_app_name_son" +
    " where (" +
    " case when(sn.item_app_name_son is null or sn.item_app_name_son = '') then sn.item_app_name" +
    " else concat(sn.item_app_name, '_', sn.item_app_name_son) end) in " + xtStr;
if (isNotNull(search_pt)) {
    sql = sql + " and sn.ITEM_SYSTEM_TYPE like '%" + search_pt + "%'";
}
if (isNotNull(search_xt)) {
    sql = sql + " and sn.item_app_name like '%" + search_xt + "%'";
}
if (isNotNull(search_zxt)) {
    sql = sql + " and sn.item_app_name_son like '%" + search_zxt + "%'";
}
if (isNotNull(search_sl)) {
    sql = sql + " and ina.item_instance_name like '%" + search_sl + "%'";
}
if (isNotNull(search_mk)) {
    sql = sql + " and ms.item_module like '%" + search_mk + "%'";
}
if (isNotNull(search_sljc)) {
    sql = sql + " and ina.item_instance_short like '%" + search_sljc + "%'";
}
sql = sql + " order by sn.ITEM_SYSTEM_TYPE, sn.item_app_name";
sql;